<!-- 产品编辑弹窗 -->
<template>
  <div>
    <dt-modal-edit ref='edit' :title='title' :label-width='130' okText='确定' :width='80'
      @ok='onOk'>
    </dt-modal-edit>
  </div>
</template>

<script>
  import productApi from '@/biz/modeling/product'
  import editMgr from '../opt/productOpt'
  export default {
    data() {
      return {
        info: {

        },
        title: '',
        isdisable: false
      }
    },
    methods: {
      productTypeChange() {
        let arr = []
        this.$dt.dictInfo().productType.map((item) => {
          if (this.info.productType == item.key) {
            arr = item.children
          }
        })
        return arr
      },
      hide() {
        this.$refs.edit.hide()
      },
      //新增、编辑产品
      newAddProduct(type, data) {
        console.log(data, 'newAddProduct')
        this.title = type == 'add' ? '新建产品' : '编辑产品'
        data.isJumpCommission = data.isJumpCommission == null || !data.isJumpCommission || data
          .isJumpCommission == '0' ? '0' :
          '1'
        if (type == 'edit') {
          this.info = Object.assign({}, this.info, data)
          if (data.buildingCount) {
            this.isdisable = true
          } else {
            this.isdisable = false
          }
          console.log(this.info, '保存新增、编辑产品validvalid')
        } else {
          this.constructType = []
          this.isdisable = false
          this.info = {
            productName: '', //产品名称
            coopMode: '', //合作模式
            sellMode: '', //销售模式
            productType: '', //产品类型
            buildingTypes: [], //建筑类型
            decorateSituation: '', //装修情况
            property: '', //产权年限
            propertyCompany: '', //物业公司
            propertyFree: '', //物业费
            isIndexCal: '1', //是否参与月末指标计算
            housesId: data.housesId, //案场id
            plateId: data.plateId, //地块id
            productId: '', //产品ID
            isJumpCommission: '1', //是否有跳帕佣金(1: 是 0: 否)
            commissionFeesType: '1', //代理费类型
            commissionFeesStartValue: null, //代理费起始值
            commissionFeesEndValue: null, // 代理费结束值
            generationCompany: '', //联代公司
            totalCargoQuantityCount: '', //总货量(套数)
            totalCargoQuantityArea: '', //总货量(面积)
            totalCargoQuantityValue: '', //总货量(价值)
            unitCargoQuantityCount: '', //单边货量(套数)
            unitCargoQuantityArea: '', //单边货量(面积)
            unitCargoQuantityValue: '', //单边货量(价值)
          }
        }
        this.$refs.edit.show(editMgr.options(this), this.info)
      },
      //保存新增、编辑产品
      onOk() {
        console.log(this.info, '保存新增、编辑产品validvalid')
        productApi.productSaveOrEdit(this.info).then((res) => {
          this.$Message.success('修改成功')
          this.$emit('saveProductSuccess')
          this.hide()
        })
      },
      update() {
        this.$refs.edit.show(editMgr.options(this), this.info)
      },
    },
    mounted() {

    },
  }
</script>
<style lang='scss' scoped>
  .cityList_moudle_footer {
    display: flex;
    justify-content: space-around;
    margin-top: 16px;
  }
</style>